<?php
/*
* Copyright 2009 Jan Chimiak
*
* Description: File used by to manage shouts by xhr
*/

include('../../appg/settings.php');
include('../../appg/init_ajax.php');
include('../../library/Vanilla/Vanilla.Class.CommentManager.php');
include('../../library/Vanilla/Vanilla.Class.Comment.php');
if (file_exists('../../extensions/HtmlFormatter/default.php')){
	include('../../extensions/HtmlFormatter/default.php');
}
$formatType = array_key_exists('Html',$Context->StringManipulator->Formatters) ? 'Text' : 'Html';


foreach($_GET as $key => $value) {
    $$key = stripslashes($value);
}

if (isset($shout) && $shout !="" && $Context->Session->UserID > 0){
	
	$cm = new CommentManager($Context);
	$comment = new Comment($Context);
	
	$dataset = array('DiscussionID'=>$Context->Configuration['SHOUT_DISCUSSIONID'], 'Body'=>$shout, 'FormatType'=>$formatType);
	$comment->GetPropertiesFromDataSet($dataset,$Context->Session->UserID);
	$response = $cm->SaveComment($comment);
	if($response->CommentID){
		echo '<li><div><span class="ShoutUser Today">'.$Context->Session->User->Name.'</span>: <span class="ShoutBody">'.$response->Body.'</span></div></li>';
	}
}
$Context->Unload();
?>